package cn.lsh.main;

import cn.lsh.mapper.WordMapper;
import cn.lsh.reducer.HbaseReduce;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class HbaseDriver {

	public static void main(String[] args) throws Exception {
		Configuration conf = new Configuration(true);
		//需要通过zk连接hbase
		conf.set("hbase.zookeeper.property.clientPort", "2181");
		conf.set("hbase.zookeeper.quorum", "node01,node02,node03");

		Job job = Job.getInstance(conf, "Hbase_MR");
		job.setJarByClass(HbaseDriver.class);

		job.setMapperClass(WordMapper.class);
		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(IntWritable.class);

		//reduce输出到hbase
		TableMapReduceUtil.initTableReducerJob("total", HbaseReduce.class, job, null, null, null,null,true);

		FileInputFormat.addInputPaths(job, "/hadoopusers/ncdc/input/item_user.txt");
		//输出到hbase
		// FileOutputFormat.setOutputPath("");
		job.waitForCompletion(true);
	}

}
